package main

var result [][]int

func subsets(nums []int) [][]int {
	result = nil
	doSubset(nums, []int{}, 0)
	return result
}

func doSubset(nums []int, list []int, pos int) {
	item := make([]int, len(list))
	copy(item, list)
	result = append(result, item)
	for i := pos; i < len(nums); i++ {
		list = append(list, nums[i])
		doSubset(nums, list, i+1)
		list = list[0 : len(list)-1]
	}
}

func main() {
	r := subsets([]int{1, 2})
	println(r)
}
